import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/component',
    name: 'component',
    component: () => import('../views/Component.vue'),
    //路由重定向 当直接访问component ，自动跳转到该路径
    redirect:'/component/a',

    children:[
      {
        path: 'table',
        name: 'table',
        component: () => import('../views/Table.vue'),
      },
      {
        path: 'c',
        name: 'c',
        component: () => import('../views/C.vue'),
      },
      {
        path: 'b',
        name: 'b',
        component: () => import('../views/B.vue'),
      },
      {
        path: 'a',
        name: 'a',
        component: () => import('../views/A.vue'),
      },
    ]
  },
  {
    path: '/container',
    name: 'container',
    component: () => import('../views/Container.vue'),
  },
  // {
  //   path: '/nav',
  //   name: 'nav',
  //   component: () => import('../views/Nav.vue'),
  // },
  {
    path: '/',
    name: '首页',
    component: Login,
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
